package pl.nazaweb.imedproplus.model.facade;

import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import pl.nazaweb.imedproplus.model.entity.Patient;

/**
 *
 * @author naza
 */
@Stateless
@LocalBean
public class PatientFacade extends AbstractFacade<Patient> {

    @PersistenceContext(unitName = AbstractFacade.peristanceUnitName)
    private EntityManager entityManager;

    public PatientFacade() {
        super(Patient.class);
    }

    @Override
    protected EntityManager getEntityManager() {
        return this.entityManager;
    }

    @Override
    public void remove(Patient entity) {
        this.getEntityManager().createNativeQuery("delete from patient where id="+entity.getId()).executeUpdate();
    }

    @Override
    public void remove(List<Patient> entityList) {
        for(Patient p : entityList){
            this.remove(p);
        }
    }
}
